package cn.schoolwow.util.test.module.query.resource.testcase;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.domain.query.resource.QueryResource;
import cn.schoolwow.util.test.module.common.domain.User;
import org.junit.Assert;

import java.util.List;

public class GetAsInstanceListTestCaseFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        List<User> userList = QueryResource.newQuery("用户数组","module/query/resource/userArray.json")
                .execute()
                .getAsInstanceList(User.class);
        Assert.assertEquals(1, userList.size());
        User user = userList.get(0);

        Assert.assertEquals("zhangsan", user.username);
        Assert.assertEquals("123456", user.password);
    }

    @Override
    public String name() {
        return "读取用户JSONArray并返回User列表测试用例";
    }
}
